import requests

from basic.base_request import BaseMerchantRequest
from basic.config import ENV


class url:
    Finance_Funds1 = ENV.MER_HOST+'/api/admin/merchant/finance/funds/flow'
    Finance_Record1 = ENV.MER_HOST+'/api/admin/merchant/finance/closing/record/list'
    Finance_Apply1 = ENV.MER_HOST+'/api/admin/merchant/finance/closing/apply'
    Finance_Daily1 = ENV.MER_HOST+'/api/admin/merchant/finance/daily/statement/list'

class MerchantFinance(BaseMerchantRequest,url):

    def __init__(self):
        super().__init__()
        self.coupon_list = None

    def Finance_Funds(self,orderNo=None,dateLimit=None):
        # 资金流水查询
        params = {
            'orderNo': orderNo,
            'dateLimit': dateLimit,
            'page': '1',
            'limit': '20',
            'temp': '1754096939',
        }
        return self.get(self.Finance_Funds.__name__,self.Finance_Funds1,params=params)

    def Finance_Record(self,dateLimit=None,closingNo=None,auditStatus=None,accountStatus=None,closingType=None):
        # 结算记录查询
        params = {
            'dateLimit': dateLimit,
            'page': '1',
            'limit': '20',
            'closingNo': closingNo,
            'auditStatus': auditStatus,
            'accountStatus': accountStatus,
            'closingType': closingType,
            'temp': '1754097483',
        }
        return self.get(self.Finance_Record.__name__,self.Finance_Record1,params=params)

    def Finance_Apply(self,amount=10,mark=None):
        # 申请结算
        json_data = {
            'amount': amount,
            'mark': mark,
            'closingType': 'alipay',
        }
        return self.post(self.Finance_Apply.__name__,self.Finance_Apply1,json=json_data)

    def Finance_Daily(self,dateLimit=None):
        # 账单管理查询
        params = {
            'page': '1',
            'limit': '20',
            'dateLimit': dateLimit,
            'temp': '1754105798',
        }
        return self.get(self.Finance_Daily.__name__,self.Finance_Daily1,params=params)

if __name__ == '__main__':
    mf = MerchantFinance()
    print(mf.Finance_Daily('2025-08-01,2025-08-02'))
